home *** CD-ROM | disk | FTP | other *** search
- #include <graphics.h>
- #include <stdlib.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- int maxcolor;
-
- /* Initialize the graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- /* Now keep switching background colors randomly */
- maxcolor = getmaxcolor();
- /* Initialize random number generator */
- randomize();
- outtextxy(10,20, "Demonstrating setbkcolor");
- outtextxy(10,30, "Press any key to exit");
- while (!kbhit))
- {
- setbkcolor(random(maxcolor));
- delay(1000); /* Pause for 1 second */
- }
- /* Wait for 1 second, then exit */
- delay(1000);
- closegraph();
- }